#include<bits/stdc++.h>
using namespace std;
struct car
{
    long long d,v,a;
}c[100001];
long long p[100001],n,m,L,V;
bool f(int i)
{
    long long w,l;
    if(c[i].a<=0&&c[i].v<=V) return true;
    if(c[i].a==0)
    {
        if(c[i].d<=p[m])
        {
            //t[i].start=0;
            //t[i].stop=L;
            return false;
        }
        return true;
    }
    if(c[i].a<0)
    {
        l=c[i].d+(V*V-c[i].v*c[i].v)/(2*c[i].a);
        if(l<p[1]) return true;
        //t[i].start=0;
        //t[i].stop=s(l,1,m);
        return false;
    }
    l=c[i].d+(V*V-c[i].v*c[i].v)/(2*c[i].a);
    if(l>=p[m]) return true;
    //t[i].start=s(l,1,m);
    //t[i].stop=L;
    return false;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int i,T,ans1=0,ans2=0;
    cin>>T;
    while(T>0)
    {
        T--;
        ans1=0;
        cin>>n>>m>>L>>V;
        for(i=1;i<=n;i++) cin>>c[i].d>>c[i].v>>c[i].a;
        for(i=1;i<=m;i++) cin>>p[i];
        for(i=1;i<=n;i++)
        {
            if(!f(i)) ans1++;
        }
        cout<<ans1<<" ";
        if(ans1==0) cout<<m<<endl;
        else cout<<m-1<<endl;
    }
}
